﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;

namespace CMS6Tools.Common
{
    public class OrderedNameValueConfigurationCollection : ConfigurationElementCollection
    {
        #region Const
        #endregion

        #region Ctors
        public OrderedNameValueConfigurationCollection()
            : base()
        {
        }
        #endregion

        #region Properties
        #endregion

        #region Overwrite
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new OrderedNameValueConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((OrderedNameValueConfigurationElement)element).Name;
        }
        #endregion

        #region Self Methods
        public OrderedNameValueConfigurationElement this[int index]
        {
            get { return (OrderedNameValueConfigurationElement)BaseGet(index); }
            set
            {
                if (BaseGet(index) != null)
                    BaseRemoveAt(index);
                BaseAdd(index, value);
            }
        }
        #endregion
    }
}